package com.data.ferry.common;

/**
 * 枚举常量
 */
public enum EnumConstant {

    MYCAT_MYSQL_TYPE("MYCAT_MYSQL","mycat连接mysql");

    private String key;
    private String value;

    // 自定义的构造函数，参数数量，名字随便自己取
    // 构造器默认也只能是private, 从而保证构造函数只能在内部使用
    private EnumConstant(String key, String value) {
        this.key = key;
        this.value = value;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    @Override
    public String toString() {
        return this.key + ":" + this.value;
    }

    /**
     * @Title: getValue
     * @Description: TODO(根据 任意key 获取枚举对象中 value)
     * @param @param param：枚举key
     * @param @return  返回key 对应的value
     * @return String    返回类型
     * @throws
     */
    public static String getValue(String param) {
        String result="";
        EnumConstant[] allday = EnumConstant.values();
        for (EnumConstant day : allday) {
            if(day.key.equalsIgnoreCase(param)){
                result = day.value;
                break;
            }
        }
        return result;
    }

    /**
     * @Title: getValue
     * @Description: TODO(根据 任意value 获取枚举对象中 key)
     * @param @param param：枚举 value
     * @param @return  返回value 对应的key
     * @return String    返回类型
     * @throws
     */
    public static String getkey(String param){
        String result="";
        EnumConstant[] allday = EnumConstant.values();
        for (EnumConstant day : allday) {
            if(day.value.equalsIgnoreCase(param)){
                result = day.key;
                break;
            }
        }
        return result;
    }
}
